package com.jm.programming.stream;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.stream.Stream;

/**
 * @Description 并行流
 * @date 2022/7/7 18:46
 */
public class ParallelStream {
    public static void main(String[] args) {

        Integer[] arr = {1,2,3,4,6,7,8,9,10};


        Stream<Integer> stream = Stream.of(arr);
        stream.parallel()
                .peek(integer -> System.out.println(integer + "__" + Thread.currentThread().getName()))
                .filter(i -> i < 5)
                .reduce(Integer::sum)
                .orElseThrow(()-> new RuntimeException("抛出异常"));

    }
}
